package values.skill
{
	import core.manager.battle.BattleCountManager;
	import core.manager.battle.BattleEffectManager;
	
	import values.avatar.IAvatarValue;

	/**
	 *  
	 *  这个额外效果是有判断条件的  比如对方死了 或者什么的 具体条件自己写
	 * @author azhang
	 * 
	 */	
	public class JudgeDeadAdditinalEffectValue extends AdditionalEffectValue
	{	
		public static const JUDGE_ADD_PROTY:String = "judge_add_proty";
		
		public function JudgeDeadAdditinalEffectValue()
		{
			super();
		}
		
		override public function effect():void
		{
			var tempateV:AdditionalEffectTemplateValue = _skillValue.template.additional;
			//////////////////////////几率没达到///////////////////////////////
			if(!BattleCountManager.countRandom(_skillValue.getLevelValueByTag(tempateV.basePossiblity))) return;
			/////////////////////////被抵抗了/////////////////////////////////
			if(tempateV.canResist && !_skillValue.checkSkillHasLogic(LogicEffectValue.IGNORE_RESIST) && BattleCountManager.countRandom(BattleCountManager.countResistRate(_owner , _hitter))) return;
			
			var effectObj:Object = {};
			var num:Number;
			for each(var proV:AdditionalProTemplateValue in tempateV.proDic)
			{
				if(_hitter[proV.proName] != null)
				{
					if(!proV.isSpecial())
					{
						if(proV.needBaseNum || judge(proV))
						{
							num = _baseDamageNum * _skillValue.getLevelValueByTag(proV.baseNum) / 100;
							_hitter[proV.proName] -= num;
						}
						else
						{
							num = SkillNumTypeKey.getResult(proV.numType , _hitter[proV.proName] , _skillValue.getLevelValueByTag(proV.baseNum));
							_hitter[proV.proName] -= num;
						}
					}
					
					BattleEffectManager.showEffectValue(_owner , _hitter , {num:num , proName:proV.proName});
				}
			}
		}
		
		protected function judge(proV:AdditionalProTemplateValue):Boolean
		{
			switch(proV.special)
			{
				case JUDGE_ADD_PROTY:
					
					if(_kill)
					{
						return true;
					}
					
					break;
			}
			
			return false;
		}
	}
}